<?php

use App\Constant\OrderEnum;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id');
            $table->char('type')->default(OrderEnum::TYPE_GROUP)->index();
            $table->decimal('amount')->default(0);
            $table->char('order_no', 90)->index();
            $table->string('out_trade_no')->default('');
            $table->char('status', 50)->default(OrderEnum::STATUS_PENDING)->index();
            $table->string('remark')->default('');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
